﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserConTrols_ChuDe : System.Web.UI.UserControl
{
    DataProvider duLieu = new DataProvider();
    ListBox listBox = new ListBox();

    protected void Page_Load(object sender, System.EventArgs e)
    {
        if (Session["manhomhh"] != null)
        {
            string manhomhh = (String)Session["manhomhh"];
            duLieu.MakeDuLieu(listBox, manhomhh);
            DataList1.DataSource = duLieu.Load_Du_Lieu_New("select * from loaihanghoa where manhomhh=? order by maloaihh DESC", listBox);
        }
        else
        {
            DataList1.DataSource = duLieu.Load_Du_Lieu_New("select * from loaihanghoa where manhomhh=(select top 1 manhomhh from nhomhanghoa order by manhomhh DESC) order by maloaihh DESC", listBox);
        }
        DataList1.DataBind();
    }

    public string rutgonten(string noidung, int chieudai)
    {
        return "<div title='" + noidung + "'>" + (noidung.Length > chieudai ? noidung.Substring(0, chieudai-1) + "..." : noidung) + "</div>";
    }
}